#include<stdio.h>

typedef struct student
{
    int nu;
    char name[20];
    int score;
}std;

int main(void)
{
    int N;
    scanf("%d",&N);
    while (N != 0)
    {
        std s1;
        std s2;
        s2.score = 0;
        for (int i = 0; i < N; i++)
        {
            if (i == 0) 
            scanf("%d %s %d",&s1.nu,s1.name,&s1.score);
            else scanf("%d %s %d",&s2.nu,s2.name,&s2.score);
            if (s2.score>s1.score) s1 = s2;
        }
        printf("%d %s\n",s1.nu,s1.name);
        scanf("%d",&N);
    }
    
}
